/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iftk.xmlparser.domain;

import java.util.List;

/**
 *
 * @author treiman
 */
public class CourseList extends BubbleItem {
    private List<Course> courses;
    
    private BasicCourses basic;
    private IntermediateCourses intermediate;
    private AdvancedCourses advanced;
    private Seminars seminar;
    private DoctorateCourses doctorate;
    private OtherCourses other;
    
    public CourseList() {
        setBubbleTitle("Courses");
        setBubbleShort("Currently available course at the deparment of computer science");
    }

    public AdvancedCourses getAdvanced() {
        return advanced;
    }

    public void setAdvanced(AdvancedCourses advanced) {
        this.advanced = advanced;
    }

    public BasicCourses getBasic() {
        return basic;
    }

    public void setBasic(BasicCourses basic) {
        this.basic = basic;
    }

    public DoctorateCourses getDoctorate() {
        return doctorate;
    }

    public void setDoctorate(DoctorateCourses doctorate) {
        this.doctorate = doctorate;
    }

    public IntermediateCourses getIntermediate() {
        return intermediate;
    }

    public void setIntermediate(IntermediateCourses intermediate) {
        this.intermediate = intermediate;
    }

    public OtherCourses getOther() {
        return other;
    }

    public void setOther(OtherCourses other) {
        this.other = other;
    }

    public Seminars getSeminar() {
        return seminar;
    }

    public void setSeminar(Seminars seminar) {
        this.seminar = seminar;
    }
    
    public List<Course> getCourses() {
        return courses;
    }

    public void setCourses(List<Course> courses) {
        this.courses = courses;
    }
    
    public void sort() {
        basic = new BasicCourses();
        intermediate = new IntermediateCourses();
        advanced = new AdvancedCourses();
        seminar = new Seminars();
        doctorate = new DoctorateCourses();
        other = new OtherCourses();
        
        for(Course c : courses) {
            if(c != null && c instanceof Course) {
                if(c.getTaso().equals("A")) {
                    basic.add(c);
                }
                else if(c.getTaso().equals("C")) {
                    intermediate.add(c);
                }
                else if(c.getTaso().equals("L")) {
                    String tempName = c.getNimi().toLowerCase();
                    if((tempName.contains("seminar")) || (tempName.contains("seminaari"))) {                 
                        seminar.add(c);
                    }
                    else {
                        advanced.add(c);
                    }
                }
                else if(c.getTaso().equals("J")) {
                    doctorate.add(c);
                }
                else {
                    other.add(c);
                }
            }
        }
    
    }
}
